<template>
  <div class="water-machine-history">
    <c-title text="历史记录"></c-title>
    <div class="box" v-for="(item,i) in list" :key="i">
      <div class="flex-between">
        <span style="font-size: 0.9375rem; font-weight: 600;">{{item.device_no}}</span>
        <span style="color: #fe5e56;">{{item.status_name}}</span>
      </div>
      <div class="address">
        <span style="text-align: left;">
          地址:{{ item.device.address }}
        </span>
        <span style="margin-left: 1.7188rem; flex-shrink: 0;">支付：¥{{ item.order.price }}</span>
      </div>
      <p style="margin-top: 0.1875rem; color: #7e7e7e; font-size: 0.75rem; text-align: left;">{{item.order.order_sn}}</p>
      <p style="margin-top: 0.1875rem; color: #7e7e7e; font-size: 0.75rem; text-align: left;">{{item.created_at}}</p>
    </div>
  </div>
</template>

<script>
import { scrollMixin } from '../../utils/mixin';
export default {
  mixins:[scrollMixin],
  data() {
    return {
      page:1,
      last_page:1,
      list:[],
      isLoadMore:true,
    };
  },
  activated(){
    this.isLoadMore = true;
    this.getData()
  },
  methods: {
    getMoreData(){
      this.isLoadMore = false;
      if(this.page>=this.total_page){return};
      let page = this.page + 1;
      this.getData(page);
    },
    getData(page=1){
      $http.get("plugin.water-machine.frontend.consumer.without-card.index",{page},"").then(res=>{
        if(res.result){
          this.page = res.data.current_page;
          this.total_page = res.data.last_page;
          (page==1)?(this.list=res.data.data):(this.list = this.list.concat(res.data.data));
        }else{
          this.$toast(res.msg);
        }
      })
    }
  }
};
</script>

<style scoped lang="scss">
.water-machine-history {
  padding: 0.75rem;

  .flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .box {
    background: #fff;
    border-radius: 0.625rem;
    padding: 1rem 0.625rem;
    margin-bottom: 0.8125rem;
  }

  .address {
    margin-top: 0.375rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 400;
    color: #7e7e7e;
  }
}
</style>
